{include file="public/header" select="0" /}
<style>
    .color{
        color: #FFA500 !important;
    }
    .register .code{
        border: none;
        color: #fff;
        border-radius: 1rem;
        font-size: .6rem;
        height: 1.2rem;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f54319;
    }
</style>
<body>

<div class="title bgc">
    <i class="layui-icon layui-icon-left" onclick="goBack()"></i>
    注册
</div>
<form action="{:url('register/add')}" method="post" class="form">
    <div class="bgc login-news register-news">
        <ul class="register">
            <input type="hidden" name="web" value="1">
            <!--<li>
                <p>用户名</p><input type="text" name="account" placeholder="请填写用户名">
            </li>-->
            <!--<li>
                <p>昵称</p><input type="text" name="nickname" placeholder="请填写昵称">
            </li>-->
            <li>
                <p>手机号</p><input type="number" name="mobile" value="" placeholder="请填写手机号">
            </li>
            <!--<li>
                <p>验证码</p>
                <input type="text" name="captcha" placeholder="请输入验证码">
                <span class="code " >获取验证码</span>
                <span class="test">60</span>
            </li>-->
            <li>
                <p>推荐人</p>
                <input type="text" name="parent_code" value="{$code}" placeholder="请填写推荐人" readonly="readonly">
            </li>
            <li>
                <p>登录密码</p>
                <input type="password" name="password" class="psd" placeholder="请填写登录密码">
            </li>
            <li>
                <p>确认登录密码</p>
                <input type="password" name="password_confirm" class="psd" placeholder="请确认登录密码">
            </li>
            <li>
                <p>支付密码</p>
                <input type="password" name="pay_password" class="psd" placeholder="请填写支付密码">
            </li>
            <li>
                <p>确认支付密码</p>
                <input type="password" name="pay_password_confirm" class="psd" placeholder="请确认支付密码">
            </li>
            <li class="layui-form" style="height: auto">
                <p style="width: 25%">所在地区</p>
                <div class="sunSelect address-select" style="display: block;" data-url="{:url('register/getArea')}" data-value="code" data-name="title">
                    <select name="province" data-name="请选择省" data-level="1" data-id="{$info?$info.province:''}" lay-verify="required"
                            lay-reqtext="请选择省" lay-verType="tips" lay-filter="sunSelect"></select>
                    <select name="city" data-name="请选择市" data-level="2" data-id="{$info?$info.city:''}" lay-verify="required"
                            lay-reqtext="请选择市" lay-verType="tips" lay-filter="sunSelect"></select>
                    <select name="district" data-name="请选择区/县" data-level="3" data-id="{$info?$info.district:''}" lay-verify="required"
                            lay-reqtext="请选择区/县" lay-verType="tips" lay-filter="sunSelect"></select>
                </div>
            </li>
        </ul>
        <!--<div class="login-hint register-hint">
            <p></p>
            <p>已有账号，<a href="{:url('login/index')}">去登录</a></p>
        </div>-->
        <div class="pay-btn register-btn" style="background:#F54319;">
            <a href="javascript:;" lay-submit lay-filter="save" formObj=".form" >注册</a>
        </div>
        <p class="register-deal">
            <input type="checkbox" name="agree" style="width: .7rem;height: .7rem;display: inline-block;max-width: 1.8rem" lay-skin="primary" value="1" checked>
            <span style="margin-left: 5px">同意协议</span>
            <a href="{:url('agreement')}?type=register_msg" style="color: #F54319">《{:cache('system')['web_site_title']}注册协议》</a>
        </p>

        <input type="hidden" name="lng" value="">
        <input type="hidden" name="lat" value="">
    </div>
</form>

</body>
{include file="public/footer" select="0" /}

<script>
    var isSend = false;
    $('.code').click(function () {
        if (isSend) return;
        let mobile = $('input[name="mobile"]').val();
        if (mobile.length < 1) {
            layer.msg('请输入手机号码'); return;
        }
        var _this = this;
        var n = 60;
        $.ajax({
            type: 'post',
            url: "{:url('index/sendSms')}",
            data: {
                mobile: $.trim(mobile)
            },
            dataType: "json",
            success: function (data) {
                if (data.code == 1) {
                    $(_this).text(n + 's后重新发送');
                    isSend = true;
                    var timer = setInterval(function () {
                        n--;
                        $(_this).text(n + 's后重新发送');
                        if (n <= 0) {
                            isSend = false;
                            clearInterval(timer);
                            $(_this).text('获取验证码');
                        }
                    }, 1000);
                } else {
                    layer.msg(data.msg);
                }
            }
        });
    });

    /*var x = document.getElementById('demo');

    $(function (){
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition, showError);
        } else {
            //x.innerHTML = '当前浏览器不支持地理定位';
        }

    });

    // 获取定位成功，显示位置信息
    function showPosition(position) {
        let lng = position.coords.longitude;// 经度
        let lat = position.coords.latitude;// 纬度
        $("input[name='lng']").val(lng)
        $("input[name='lat']").val(lat)
        // x.innerHTML =
        //     'Latitude(纬度): ' + position.coords.latitude + // 纬度
        //     '<br>Longitude(经度): ' + position.coords.longitude; // 经度
    }
    // 获取定位失败，显示错误信息
    function showError(error) {
        switch (error.code) {
            case error.PERMISSION_DENIED:
                //x.innerHTML = '用户拒绝地理定位请求';
                break;
        }
    }*/

    (function () {
        if (typeof WeixinJSBridge === 'object' && typeof WeixinJSBridge.invoke === 'function') {
            handleFontSize()
        } else {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', handleFontSize, false)
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', handleFontSize)
                document.attachEvent('onWeixinJSBridgeReady', handleFontSize)
            }
        }
        function handleFontSize () {
            // 设置网页字体为默认大小
            WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
            // 重写设置网页字体大小的事件
            WeixinJSBridge.on('menu:setfont', function () {
                WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
            })
        }
    })()

    
</script>
</html>